﻿using my.abp.Domain.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.Domain;
using Volo.Abp.Modularity;
using Framework.Caching.FreeRedis;
using Microsoft.Extensions.DependencyInjection;
using Framework.Core.Operlog;
using my.abp.Domain.Authorization;
using Volo.Abp.EventBus.RabbitMq;
using Microsoft.Extensions.Configuration;
using Volo.Abp.RabbitMQ;

namespace my.abp.Domain
{
	/// <summary>
	/// 领域层 模块
	/// </summary>
	[DependsOn(
		typeof(MyAbpDomainSharedModule), // 领域共享层 模块
		typeof(AbpDddDomainModule),                 // 集成 用于支持领域驱动设计（DDD）领域层开发 模块
		typeof(AbpEventBusRabbitMqModule),          // 集成 分布式事件总线RabbitMQ 模块
		typeof(FrameworkCachingFreeRedisModule)		// 缓存管理 模块
		)]
	public class MyAbpDomainModule : AbpModule
	{
		public override void ConfigureServices(ServiceConfigurationContext context)
		{
			var service = context.Services;
			var configuration = context.Services.GetConfiguration();
			service.AddControllers(options =>
			{
				options.Filters.Add<PermissionGlobalAttribute>();
				options.Filters.Add<OperLogGlobalAttribute>();
			});

			// 读取 分布式事件总线RabbitMQ 配置
			Configure<AbpRabbitMqOptions>(configuration.GetSection("RabbitMQ:Connections"));
			Configure<AbpRabbitMqEventBusOptions>(configuration.GetSection("RabbitMQ:EventBus"));
		}
	}
}
